
class CSoundDeviceFactory;
void RegisterSoundDeviceFactory(CSoundDeviceFactory* factory);
ISoundDevice* SoundDeviceFactory(const char* type);
void OutputSNDList();

typedef ISoundDevice*(*SndInterfaceInitcall)();
class CSoundDeviceFactory {
	private:
		SndInterfaceInitcall InitCall;
		const char* name;
		int interfaceversion;

	public:
		CSoundDeviceFactory(const char* name, int intf_version, SndInterfaceInitcall initcall) {
				this->name = name;
				this->interfaceversion = intf_version;
				this->InitCall = initcall;
				RegisterSoundDeviceFactory(this);
		}

		const char* GetName() { return this->name; }
		
		int GetInterfaceVersion() { return this->interfaceversion; }
		
		ISoundDevice* Init() { return InitCall(); }
};

// Legacy sound factory. Don't use this if you're using the current version!
#define LEGACY_SOUND_FACTORY(name, version, class)\
	ISoundDevice* class##_Factory() {\
			return new CLegacySoundDevice(new class);\
	}\
	CSoundDeviceFactory class##factory(name,version,class##_Factory);

// Main sound factory.
#define SOUND_FACTORY(name,version,class)\
ISoundDevice* class##_Factory() {\
		Msg("Creating new sound device " name"\n");\
		return new class;\
}\
CSoundDeviceFactory class##factory(name,version,class##_Factory);